﻿Partial Public Class Window
    ''' <summary>
    ''' Gets or sets the default background color for cells in this window.
    ''' </summary>
    ''' <returns></returns>
    Public Property BackColor As ConsoleColor = Console.BackgroundColor

    ''' <summary>
    ''' Gets or sets the outter most bounds of the window (includes border).
    ''' </summary>
    ''' <returns>A Rectangle structure containing the bounds of the window.</returns>
    Public Property Bounds As Rectangle
        Get
            Return _Bounds
        End Get
        Set(value As Rectangle)
            _Bounds = value
            UpdateInternalBounds()
        End Set
    End Property

    ''' <summary>
    ''' Gets or sets a value determining whether or not this window can receive input focus.
    ''' </summary>
    ''' <returns>True if the window can receive focus, otherwise false.</returns>
    Public Property CanFocus As Boolean = True

    ''' <summary>
    ''' Gets the container of child windows belonging to this window.
    ''' </summary>
    ''' <returns>A ChildWindowCollection containing this window's child windows.</returns>
    Public ReadOnly Property Children As New ChildWindowCollection(Me)

    ''' <summary>
    ''' Gets the inner bounds of the window (excludes border).
    ''' </summary>
    ''' <returns>A Rectangle structure containing the inner bounds of this window.</returns>
    Public ReadOnly Property ClientBounds As Rectangle
        Get
            Return _ClientBounds
        End Get
    End Property

    ''' <summary>
    ''' Gets or sets the default foreground color for cells in this window.
    ''' </summary>
    ''' <returns></returns>
    Public Property ForeColor As ConsoleColor = Console.ForegroundColor

    ''' <summary>
    ''' Gets or sets the default frame color for this window.
    ''' </summary>
    ''' <returns></returns>
    Public Property FrameColor As ConsoleColor = Console.ForegroundColor

    ''' <summary>
    ''' Gets or sets a value determining if this window has a visible frame.
    ''' </summary>
    ''' <returns></returns>
    Public Property FrameVisible As Boolean
        Get
            Return _FrameVisible
        End Get
        Set(value As Boolean)
            _FrameVisible = value
            UpdateInternalBounds()
        End Set
    End Property

    ''' <summary>
    ''' Gets or sets a value determining which direction text and scrolling flow in this window.
    ''' </summary>
    ''' <returns></returns>
    Public Property InvertTextDirection As Boolean

    ''' <summary>
    ''' Gets or sets a value which determins if this window's frame is merged with it's parent's window's frame.
    ''' </summary>
    ''' <returns></returns>
    Public Property MergeFrameWithParent As Boolean = True

    ''' <summary>
    ''' Gets the parent of this window if it has been added as a child to another window.
    ''' </summary>
    ''' <returns></returns>
    Public ReadOnly Property Parent As Window

    Public ReadOnly Property Content As New WindowContent
    'Private _Text As String
    '''' <summary>
    '''' Gets or sets the string content displayed in the window.
    '''' </summary>
    '''' <returns></returns>
    'Public Property Text As String
    '    Get
    '        Return _Text
    '    End Get
    '    Set(value As String)
    '        _Text = value
    '        firstLineVisible = 0
    '    End Set
    'End Property

    '''' <summary>
    '''' Gets the number of lines of string content displayed in the window.
    '''' </summary>
    '''' <returns></returns>
    'Public ReadOnly Property TextLineCount As Integer

    ''' <summary>
    ''' Gets or sets a value determining whether or not the window is visible.
    ''' </summary>
    ''' <returns></returns>
    Public Property Visible As Boolean
        Get
            Return _Visible
        End Get
        Set(value As Boolean)
            If Not _Visible = value Then
                If Not value Then
                    needsErased = True
                    Hide()
                Else
                    Show()
                End If
            End If
        End Set
    End Property

    ''' <summary>
    ''' Gets the z-order of this window in relation to all other windows.
    ''' </summary>
    ''' <returns></returns>
    Public ReadOnly Property ZOrder As Integer
        Get
            Return openWindows.IndexOf(Me)
        End Get
    End Property

End Class
